package mapreduce.phonenum;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;


public class MyPartitioner extends Partitioner<Text,Bean> {
    @Override
    public int getPartition(Text text, Bean bean, int i) {
        String phone = text.toString();
        String subPhone = phone.substring(0, 3);
        int partition;
        switch (subPhone){
            case "136": partition = 0; break;
            case "137": partition = 1; break;
            case "138": partition = 2; break;
            case "139": partition = 3; break;
            default:partition = 4;
        }
        return partition;
    }
}
